<extend name="template/base_index" />

<block name="area_header">

    <style type="text/css">
        .sku-panel-wrp p{
            margin: 0px;
        }
        .sku-panel-wrp,.sku-panel-wrp a{

            font-size: 12px;
        }
        .sku-table input,.sku-table select{
            width: 50px;
        }
        .sku-table{
            font-size: 12px;
        }
        .unify table tr {
            height: 25px;
            line-height: 25px;
        }

        .unify table tr th, .unify table tr td {
            text-align: center;
        }
        input{
            max-width: 120px;
        }
    </style>
    <link rel="stylesheet" type="text/css" media="all" href="__CSS__/wxshop.css">
    <link type="text/css" rel="stylesheet" src="__CDN__/jquery-uploadify/3.2.1/uploadify.css" />
    <script type="text/javascript" src="__CDN__/jquery-uploadify/3.2.1/jquery.uploadify.min.js"></script>
    <link type="text/css" rel="stylesheet" href="__CDN__/select2/3.5.2/select2.css" />
    <script type="text/javascript" src="__CDN__/select2/3.5.2/select2.min.js"></script>
    <script type="text/javascript" src="__CDN__/select2/3.5.2/select2_locale_zh-CN.js"></script>
    <link rel="stylesheet" type="text/css" media="all" href="__CDN__/jquery-datetimepicker/jquery.datetimepicker.css">
    <script type="text/javascript" src="__CDN__/jquery-datetimepicker/jquery.datetimepicker.js"></script>
</block>

<block name="area_body">
    {:W('Menus/topbar')}
    <div class="admin-main container-fluid">
        {:W('Menus/left')}
        <div class="admin-main-content">
            {:W('Menus/breadcrumb')}

            <div class="col-main">
                <div class="main-hd">
                    <h2>编辑商品</h2>
                </div>
                <div class="main-bd clearfix" style="padding: 0 10px;margin-top: 0px;">
                <form class="productForm form-horizontal" method="post">
                    <input type="hidden" name="id" value="{$vo.id}" />
                    <input  type="hidden" class="sku_list" name="sku_list" value=""/>
                    <input type="hidden" name="main_img" id="main_img" value="{$vo.main_img}" />
                    <input type="hidden" name="img" id="img" value="{$vo.img}" />
                    <input type="hidden" name="img_post" id="img_post" value="{$vo.img_post}" />
                    <input type="hidden" name="img_post_bg" id="img_post_bg" value="{$vo.img_post_bg}" />
                    <input type="hidden" name="store_id" value="{$vo.store_id}" />
                    <h3><i>●</i>基本信息</h3>
                    <div class="form-group col-lg-12 col-md-12 clearfix">
                        <label for="" class="control-label col-lg-2 col-md-2">商品类别</label>
                        <div class="col-lg-10 col-md-10">
                            <volist name="cate_name" id="cate_value">
                                {$cate_value}/
                            </volist>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix">
                        <label for="" class="control-label col-lg-2 col-md-2">商品名称</label>
                        <div class="col-lg-10 col-md-10">
                            <input name="product_name" maxlength="60" value="{$vo.name}" class="js_product_name form-control input-normal input-sm" />
                            <span class="help-block">限30个字</span>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix hide">
                        <label for="" class="control-label col-lg-2 col-md-2">标签</label>
                        <div class="col-lg-10 col-md-10">
                            <input name="secondary_headlines" maxlength="60" value="{$vo.secondary_headlines}" class="js_product_name form-control input-normal input-sm"/>
                            <span class="help-block">限500字</span>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix">
                        <label for="" class="control-label col-lg-2 col-md-2">商品编号</label>
                        <div class="col-lg-10 col-md-10">
                            <input name="product_code" maxlength="60" value="{$vo.product_code}" class="form-control input-normal input-sm"/>
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix hide">
                        <label for="" class="control-label col-lg-2 col-md-2 ">商品分组
                            <br/><span class="help-block"></span>
                        </label>
                        <div class="col-lg-10 col-md-10">
                            <select name="product_group" class="js_product_group select2">
                                <option value="0">=请选择=</option>
                                {:W("Partials/datatree",array(getDatatree('WXPRODUCTGROUP'),true,$product_group))}
                            </select>
                        </div>
                        <div class="js_group_time <eq name='product_group' value='0'>hide</eq>" style="margin-left: 280px">
                            <label>起始时间:</label>&nbsp;<input type="text" class="form-control input-normal input-sm startdatetime" name="group_start_time" value="{$group_start_time|date='Y-m-d G:i:s',###}"/>&nbsp;&nbsp;
                            <label>终止时间:</label>&nbsp;<input type="text" class="form-control input-normal input-sm enddatetime" name="group_end_time" value="{$group_end_time|date='Y-m-d G:i:s',###}"/>
                        </div>
                    </div>
                    <div class="js_prop form-group col-lg-12 col-md-12 clearfix">
                        <label  class="control-label col-lg-2 col-md-2">商品属性
                            <br/><span class="help-block">(选填)</span>
                        </label>
                        <div class="col-lg-10 col-md-10">
                            <div class="well">
                                <div class="loading">
                                    <img src="__CDN__/common/loading.gif" />
                                </div>
                                <div class="prop-list clearfix">

                                </div>
                                <hr>
                                <div class="btn-controls hidden">
                                    <a href="{:U('Admin/CategoryProp/add',array('cate_id'=>$cate_id))}" target="_blank" class="btn btn-sm btn-primary"><i class="fa fa-plus"></i>添加属性</a>
                                    <a href="javascript:void(0);"  class="btn btn-sm btn-primary js_prop_refresh"><i class="fa fa-refresh"></i>刷新</a>
                                </div>

                            </div>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix">
                        <label  class="control-label col-lg-2 col-md-2">商品图片</label>
                        <div class="col-lg-10 col-md-10">
                            主图<span class="text-muted">(建议尺寸为640像素*640像素，大小不超过500kb)<i data-toggle="tooltip" class="fa fa-question" title="商品主图将会作为商品的默认图片出现在货架及商品详情页。"></i></span>
                            <!-- 图片选择DOM结构 -->
                            <div class="wxuploaderimg main_img clearfix <notempty name="vo.main_img">checked</notempty>"  data-maxitems="1">
                            <div class="img-preview clearfix" >
                                <notempty name="vo.main_img">
                                    <div class="pull-left clearfix img-item">
                                        <img src="{:getImgUrl($vo['main_img'],120)}" data-imageid="{$vo.main_img}"/>
                                        <div class="edit_pic_wrp"><a href="javascript:;" class="fa fa-lg fa-trash js_delete"></a></div>
                                    </div>
                                </notempty>
                            </div>
                            <div class="add">
                                <i class="fa fa-plus"></i>
                            </div>
                        </div>
                        <!-- 图片选择DOM结构 -->
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix">
                        <label  class="control-label col-lg-2 col-md-2">&nbsp;</label>
                        <div class="col-lg-10 col-md-10">
                            其他图片<span class="text-muted">(选传，单张图片大小不超过500kb，最多10张)<i class="fa fa-question" data-toggle="tooltip" title="将出现在商品图片库，方便用户更好的了解您的商品。"></i></span>
                            <!-- 图片选择DOM结构 -->
                            <div class="wxuploaderimg clearfix product-imglist "  data-maxitems="10">
                                <div class="img-preview clearfix" <if condition="count($imgs) gt 0">style="display:inline-block;"</if>>
                                <if condition="count($imgs) gt 0">
                                    <volist name="imgs" id="one">
                                        <div class="pull-left clearfix img-item">
                                            <img src="{:getImgUrl($one,120)}" alt="image" data-imageid="{$one}"/>
                                            <div class="edit_pic_wrp"><a href="javascript:;" class="fa fa-lg fa-trash js_delete"></a></div>
                                        </div>
                                    </volist>
                                </if>
                            </div>
                            <div class="add" <if condition="count($imgs) eq 10">style="display:none;"</if> >
                            <i class="fa fa-plus"></i>
                        </div>
                    </div>

                <!-- 图片选择DOM结构 -->
                    </div>
                </div>
                <div class="form-group col-lg-12 col-md-12 clearfix">
                    <label for="synopsis" class="col-md-2 col-lg-2 control-label">商品简介</label>
                    <div class="col-md-10 col-lg-10">
                        <textarea name="synopsis" id="synopsis" class="form-control" rows="5">{$vo.synopsis}</textarea>
                        <div class="help-block">(您最多可以输入500个字)</div>
                    </div>
                </div>


            <div class="js_sku form-group col-lg-12 col-md-12 clearfix">

                <label class="control-label col-lg-2 col-md-2">商品规格<span class="help-block">(只有选中的前4种有效)</span></label>
                <div class="col-lg-10 col-md-10">
                    <include file="Product:inner_sku" />
                </div>
            </div>

                    <div class="form-group col-lg-12 col-md-12 clearfix hide ">
                        <label  class="control-label col-lg-2 col-md-2 ">计量单位
                            <br/><span class="help-block"></span>
                        </label>
                        <div class="col-lg-10 col-md-10">
                            <select name="dt_goods_unit" style="width: 100px;" class="select2 dt_goods_unit input-normal" >
                                {:W("Partials/datatree",array(getDatatree('GOODSUNIT'),true,$vo['dt_goods_unit'],1))}
                            </select>
                        </div>
                    </div>

            <div class="form-group col-lg-12 col-md-12 clearfix js_frm_gp_sku" >
                <label for="" class="control-label col-lg-2 col-md-2">重量
                    <br/><span class="help-block"></span>
                </label>
                <div class="col-lg-10 col-md-10">
                    <input name="weight" maxlength="60" value="{$vo.weight}"  class="oriprice form-control input-short input-sm"  style="width:100px;"/>  g/m<sup>2</sup>
                    <span class="help-block">商品每米的重量(毛重)，单位：g/m<sup>2</sup> </span>
                </div>
            </div>

                    <div class="hide form-group col-lg-12 col-md-12 clearfix js_frm_gp_sku">
                        <label for="contact_way" class="control-label col-lg-2 col-md-2 ">商品产地<br/>
                        </label>
                        <div class="col-lg-10 col-md-10">
                            <input name="place_origin" id="place_origin" value="{$vo.place_origin}"  class="form-control input-short input-sm"/>
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix hide">
                        <label  class="control-label col-lg-2 col-md-2">七天无理由退换货支持</label>
                        <div class="col-lg-10 col-md-10">
                            <label class="radio-inline">
                                <input type="radio" name="under_guaranty" <eq name="vo['under_guaranty']" value="0">checked="checked"</eq> value="0">不支持
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="under_guaranty" <eq name="vo['under_guaranty']" value="1">checked="checked"</eq>  value="1">支持
                            </label>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix hide">
                        <label  class="control-label col-lg-2 col-md-2">是否支持混批</label>
                        <div class="col-lg-10 col-md-10">
                            <label class="radio-inline">
                                <input type="radio" name="can_mixed_batch" <eq name="vo['can_mixed_batch']" value="0">checked="checked"</eq> value="0">不支持
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="can_mixed_batch" <eq name="vo['can_mixed_batch']" value="1">checked="checked"</eq>  value="1">支持
                            </label>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix hide">
                        <label  class="control-label col-lg-2 col-md-2">是否提供色卡</label>
                        <div class="col-lg-10 col-md-10">
                            <label class="radio-inline">
                                <input type="radio" name="has_sample" <eq name="vo['has_sample']" value="0">checked="checked"</eq> value="0">否
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="has_sample" <neq name="vo['has_sample']" value="1">checked="checked"</neq> value="1">是
                            </label>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix js_frm_gp_sku">
                        <label for="consignment_time" class="control-label col-lg-2 col-md-2 ">发货时间<br/>
                        </label>
                        <div class="col-lg-10 col-md-10">
                            <input name="consignment_time" id="consignment_time" value="{$vo.consignment_time}" class="form-control input-short input-sm"/>天
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix js_frm_gp_sku">
                        <label for="expire_time" class="control-label col-lg-2 col-md-2 ">下架时间<br/>
                        </label>
                        <div class="col-lg-10 col-md-10">
                            <input name="expire_time" id="expire_time" value="{$vo.expire_time|date='Y-m-d H:i:s',###}" class="form-control input-short input-sm"/>
                            <span class="help-block"></span>
                        </div>
                    </div>

                    <div class="form-group col-lg-12 col-md-12 clearfix js_frm_gp_sku">
                        <label class="control-label col-lg-2 col-md-2 ">商品总销量
                            <br/><span class="help-block"></span>
                        </label>
                        <div class="col-lg-10 col-md-10">
                            <input name="total_sales" maxlength="60" value="{$vo.total_sales}" class="form-control input-short input-sm" />
                        </div>
                    </div>


            <div class="form-group col-lg-12 col-md-12 clearfix">
                <h4>客服信息</h4>
            </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix js_frm_gp_sku">
                        <label for="contact_name" class="control-label col-lg-2 col-md-2 ">联系人姓名<br/>
                        </label>
                        <div class="col-lg-10 col-md-10">
                            <input name="contact_name" id="contact_name" value="{$vo.contact_name}" class="form-control input-short input-sm"/>
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12 clearfix js_frm_gp_sku">
                        <label for="contact_way" class="control-label col-lg-2 col-md-2 ">联系方式<br/>
                        </label>
                        <div class="col-lg-10 col-md-10">
                            <input name="contact_way" id="contact_way" value="{$vo.contact_way}"  class="form-control input-short input-sm"/>
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <h3 class="pull-left hide"><i>●</i>售后信息</h3>
                    <div class="form-group col-lg-12 col-md-12 clearfix hide">
                        <label  class="control-label col-lg-2 col-md-2">退换货</label>
                        <div class="col-lg-10 col-md-10">
                            <label class="radio-inline">
                                <input type="radio" name="support_replace" <eq name="vo['support_replace']" value="0">checked="checked"</eq>   value="0">不支持
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="support_replace" <eq name="vo['support_replace']" value="1">checked="checked"</eq>   value="1">支持
                            </label>
                        </div>
                    </div>

            <div class="form-group col-lg-12 col-md-12 clearfix">
                <h4>物流信息</h4>
            </div>
            <div class="form-group col-lg-12 col-md-12 clearfix">
                <label for="contact_way" class="control-label col-lg-2 col-md-2 "><span class="danger">*</span>请选择运费<br/>
                </label>
                <div class="col-lg-10 col-md-10">
                    <select id="freight_template" name="template_id"
                            class="select2 input-short  input-sm">
                        <option value="0">卖家承担运费（包邮）</option>
                        <volist name="freight_template" id="tpl">
                            <option <eq name="vo['template_id']" value="$tpl['id']">selected</eq> value="{$tpl.id}">{$tpl.name}</option>
                        </volist>
                    </select>
                    <span class="help-block">卖家承担运费为包邮，选择其它为使用运费模板,前往<a href="{:U('Admin/FreightTemplate/index')}" target="_blank">【运费模板管理】</a>进行管理运费模板</span>
                </div>
            </div>

                <div class="form-group col-lg-12 col-md-12 clearfix tool-bar text-center border">
                    <div class="col-lg-6 col-md-6">
                        <a target-form="productForm" href="{:U('Admin/Product/edit')}" onclick="return check();"  class="ajax-post btn btn-primary btn-block" id="js_submit"><i class="fa fa-check"></i>确定</a>
                    </div>
                    <div class="col-lg-6 col-md-6">
                        <a href="{:U('Admin/Product/index',array('store_id'=>$vo['store_id'],'onshelf'=>$onshelf,'p'=>$p))}" class="btn btn-default btn-block"><i class="fa fa-reply"></i>返回</a>
                    </div>
                </div>
             </form>
        </div>
    </div>

    <include file="template/wxpicture" />
    </div>
    <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
</block>

<block name="area_footer">
    <script type="text/javascript" >
        var prop_value_ids = {$props_value_ids};
    </script>


    <script type="text/javascript">
        window.ServicesURL = {
            groupGetAll:"{:U('Admin/WxshopGroup/groups')}",
            groupAdd:"{:U('Admin/WxshopGroup/add')}",
            cateAllProp:"{:U('Admin/Category/cateAllProp')}",
            skulist:"{:U('Admin/Product/skulist')}",
        };
    </script>
    <script type="text/javascript">
        //国别选择时的操作
        function initCountry(){
            $(".dt_origin_country").change(function(){
                var val = $(".dt_origin_country").find("option:selected").text();
                $("input[name='source']").val(val);
            });
            $(".dt_origin_country").change();
        }

        //初始化select2 控件
        function initSelect2(){
            $('select.select2').select2();
        }

        function getData(){

            var main_img = $(".main_img .img-preview img").attr("data-imageid");
            if(main_img){
                $("#main_img").val(main_img);
            }

            $("#img").val("");
            $(".product-imglist .img-preview img").each(function(index,item){
                $("#img").val($("#img").val()+$(item).attr("data-imageid")+",");
                //alert($("#img").val());
            });


            var img_post = $(".img_post .img-preview img").attr("data-imageid");
            if(img_post){
                $("#img_post").val(img_post);
            }

            var img_post_bg = $(".img_post_bg .img-preview img").attr("data-imageid");
            if(img_post_bg){
                $("#img_post_bg").val(img_post_bg);
            }
            //alert($("#img").val());

            var ori_price = $("input[name='ori_price']").val();
            var price = $("input[name='price']").val();
            var cnt1 = $("input[name='cnt1']").val();
            var price2 = $("input[name='price2']").val();
            var cnt2 = $("input[name='cnt2']").val();
            var price3 = $("input[name='price3']").val();
            var cnt3 = $("input[name='cnt3']").val();
            var quantity = $("input[name='quantity']").val();
            var product_code = $("input[name='product_code']").val();
            var sku_list = getSkuData();
            $("input.sku_list").val(sku_list);
            var vip_price = [];
            $("input[name='vip_price']").each(function () {
                vip_price.push($(this).val());
            });
            if (!sku_list)return false;
            var query = {
                id: id,
                sku_list: getSkuData(),
                sku_info: getSkuInfo(),
                has_sku: $(".form input[name='has_sku']:checked").val(),
                ori_price: ori_price,
                price: price,
                cnt1: cnt1,
                price2: price2,
                cnt2: cnt2,
                price3: price3,
                cnt3: cnt3,
                quantity: quantity,
                product_code: product_code,
                vip_price: vip_price
            };
//				console.log(query);
            if (query.sku_list.length == 0 || query.sku_info.Length == 0) {
                return false;
            }
        }


        function check(){
            getData();
            var txt = $(".js_product_name").val();
            var len = txt.replace(/[^\x00-\xff]/g, 'xx').length ;
            if(len == 0){
                $.scojs_message('商品名称必须填写', $.scojs_message.TYPE_ERROR);
                return false;
            }
            if(len > 30){
                $.scojs_message('商品名称不能超过30个字', $.scojs_message.TYPE_ERROR);
                return false;
            }
            return true;
        }

        function appendProp(list) {
            $ele = $(".js_prop .prop-list");
            $ele.empty();
            langlist = list[list.length-1];
            for(var j = 0; j <langlist.length; j++){
                //display:none 隐藏过滤
                tagwrap = $('<div style="display:none;" class="btn-group"><a class="btn btn-primary btn-sm lang" lang="'+langlist[j].value+'">'+langlist[j].name+'</a></div>');
                $ele.append(tagwrap);
            }
            for (var i = 0; i < list.length; i++) {
                //创建一个dropdown
                $propName = $('<span>' + list[i].name + '</span>');
                $prop = $('<div class="prop-value"></div>');
                $ele.append($("<div class='prop-item' ></div>").attr("data-id", list[i].id).attr('lang',list[i].lang).append($propName).append($prop));
                if (list[i].property_value) {
                    var propvaluelist = list[i].property_value;
                    for (var j = 0; j < propvaluelist.length; j++) {
                        $_propValue = $('<label></label>').text(propvaluelist[j].valuename);
                        $_propValue_check = $('<input type="checkbox" />').attr('name', 'prop[]').attr('propid',list[i].propid).val(propvaluelist[j].id);
                        if($.inArray(propvaluelist[j].id, prop_value_ids)!=-1){
                            $_propValue_check.attr('checked','checked');
                        }
                        $_propValue.prepend($_propValue_check);
                        $prop.append($_propValue);
                    }
                }
            }
            $(".prop-item[lang='zh-cn']").show();
            $(".prop-item[lang !='zh-cn']").hide();

            $(":input:checkbox").click(function(){
                //解发元素状态
                var q = $(this).prop("checked");
                var propid = $(this).attr("propid");
                //获取上级元素所在位置
                var n = $(this).parent().index();
//                console.log(n);
                //获取上上级元素
                var z = $(":input:checkbox[propid="+propid+"]").parent().parent();
//                console.log(z);
                //获取上上级元素的长度
                var x = $(":input:checkbox[propid="+propid+"]").parent().parent().length;
//                console.log(x);
                for(var i=0; i<x; i++){
                    console.log($(z[i].children).get(n));
                    console.log(q);
                    $($($(z[i].children).get(n)).children()).prop("checked",q);
                    console.log($(z[i].children).get(n));
                    console.log(q);
                }
            });
            $("a.lang").click(function(){
                var lang = $(this).attr("lang");
                $(".prop-item[lang="+lang+"]").show();
                $(".prop-item[lang!="+lang+"]").hide();
            })
        }



        //商品属性
        function queryProp() {


            $(".js_prop .loading").show();
            var last_cate = "{$cate_id}";
            $.post(window.ServicesURL.cateAllProp, {
                cate_id: last_cate
            }).done(function(data) {
                //
                if (data.status) {
                    if(data.info == null){
                        $ele = $(".js_prop .prop-list");
                        $ele.html("无属性");
                        return ;
                    }
                    appendProp(data.info);
                    $(".propsel").select2({
                        placeholder: "=选择=",
                        language: "zh-CN",
                    });
                } else {
                    $.scojs_message('刷新失败!', $.scojs_message.TYPE_ERROR);
                }
            }).always(function(){
                $(".js_prop .loading").hide();
            });
        }

        function productProp(){

            $(".js_prop .prop-list").click(function(ev){
                $ele = $(ev.target);
                if(!$ele.hasClass('link_a')){
                    return ;
                }
                $propitem = $ele.parents(".prop-item");
                $ele.addClass("selected");
                $propitem.find("button.dropdown-toggle").html($ele.text()+"<span class='caret'></span>");
            });

            setTimeout(queryProp,700);
        }

        $(function() {
            $(".js_prop_refresh").click(function(){
                queryProp();
            });
            productProp();

            //图片上传
            wxuploadimg.init({cont:".wxuploaderimg"});
            //
            $(".js_frm_gp_buylimit input[type=radio]").click(function(){

                if($(this).val() == 1){
                    $(".js_frm_gp_buylimit input[type=text]").removeClass("hidden");
                }else{
                    $(".js_frm_gp_buylimit input[type=text]").addClass("hidden");
                }
            });
            $(".js_frm_gp_buylimit input[type=radio][value=0]").click(function(){
                $(".js_frm_gp_buylimit input[type=text]").attr('value',0);
                $(".js_frm_gp_buylimit input[type=text]").val(0);
            });
            $(".js_frm_gp_buylimit input[type=text]").change(function(){
                var tmp = $(this).val();
                $(this).attr("value",tmp);
            });
            $(".js_delete:first").click(function(){
                $(".main_img .img-preview img").attr("data-imageid","");
                $("#main_img").attr("value","");
                $("#main_img").val("");
            });

            initSelect2();
            /*商品分组*/
            $('.js_product_group').click(function(){
                if($(this).val() != 0){
                    $('.js_group_time').removeClass('hide');
                }else{
                    $('.js_group_time').addClass('hide');
                }
            });

            $('.startdatetime').datetimepicker({
                lang: 'ch',
                format:'Y-m-d H:i:s',
                timepicker:false,
                timepickerScrollbar:false,
                scrollMonth:false,
                scrollTime:false,
                scrollInput:false
            });
            $('.enddatetime').datetimepicker({
                lang: 'ch',
                format:'Y-m-d  H:i:s',
                timepicker:false,
                timepickerScrollbar:false,
                scrollMonth:false,
                scrollTime:false,
                scrollInput:false
            });
            $('#expire_time').datetimepicker({
                lang: 'ch',
                format:'Y-m-d  H:i:s',
                timepicker:false,
                timepickerScrollbar:false,
                scrollMonth:false,
                scrollTime:false,
                scrollInput:false
            });

        })

    </script>

</block>